//
//  CC_Custom_CollectionReusableView.m
//  HimalayaMountain
//
//  Created by dllo on 16/7/14.
//  Copyright © 2016年 dllo. All rights reserved.
//

#import "CC_Custom_CollectionReusableView.h"

#import "CCBaseMainTitleLabel.h"
#import "CC_More_View.h"
#import "CC_Title_Model.h"
#import "CC_AnchorTitle_Model.h"

@interface CC_Custom_CollectionReusableView ()

@property(nonatomic, retain) UIImageView *imageView;
@property(nonatomic, retain) CCBaseMainTitleLabel *titleLabel;
@property(nonatomic, retain) CC_More_View *more;

@end



@implementation CC_Custom_CollectionReusableView

- (void)dealloc
{
    [_anchorTitleModel release];
    [_imageView release];
    [_more release];
    [_titleLabel release];
    [super dealloc];
}

-(instancetype)initWithFrame:(CGRect)frame{
    
    self = [super initWithFrame:frame];
    if (self ) {
        
        self.imageView = [[UIImageView alloc]init];
//        self.imageView.backgroundColor = [UIColor blackColor];
        self.imageView.image = [UIImage imageNamed:@"liveRadioCellPoint@2x.png"];
        [self addSubview:_imageView];
        [_imageView release];
        
        self.titleLabel = [[CCBaseMainTitleLabel alloc]init];
        self.titleLabel.backgroundColor = [UIColor clearColor];
        [self addSubview:_titleLabel];
        [_titleLabel release];
        
        self.more = [[CC_More_View alloc]init];
        [self addSubview:_more];
        [_more release];

    }
    return self;
}

-(void)applyLayoutAttributes:(UICollectionViewLayoutAttributes *)layoutAttributes{
    
    self.imageView.frame = CGRectMake(SPACED, SBHEIGHT * 0.3, SBWIDTH * 0.04, SBHEIGHT * 0.4);
    
    self.titleLabel.frame = CGRectMake(_imageView.bounds.size.width + SPACED, 0, SBWIDTH * 0.4, SBHEIGHT);
    
    [self.more mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.size.mas_equalTo(CGSizeMake(50, SBHEIGHT));
        make.right.equalTo(self.mas_right).offset(-SPACED);
        make.top.equalTo(self.mas_top).offset(0);
        
    }];
    
    
}

-(void)setTitleModel:(CC_Title_Model *)titleModel{
    if (_titleModel != titleModel) {
        [_titleModel release];
        _titleModel = [titleModel retain];
    }
    
    self.titleLabel.text = titleModel.title;
    
}


-(void)setAnchorTitleModel:(CC_AnchorTitle_Model *)anchorTitleModel{
    if (_anchorTitleModel != anchorTitleModel) {
        [_anchorTitleModel release];
        _anchorTitleModel = [anchorTitleModel retain];
    }
    self.titleLabel.text = anchorTitleModel.title;
    
}



@end
